package com.ruoyi.crm.controller;

import java.util.List;

import com.ruoyi.crm.domain.CrmInput;
import com.ruoyi.crm.service.ICrmInputService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 信息化投入现状Controller
 * 
 * @author ruoyi
 * @date 2023-03-30
 */
@RestController
@RequestMapping("/system/input")
public class CrmInputController extends BaseController
{
    @Autowired
    private ICrmInputService crmInputService;

    /**
     * 查询信息化投入现状列表
     */
    @PreAuthorize("@ss.hasPermi('system:input:list')")
    @GetMapping("/list")
    public TableDataInfo list(CrmInput crmInput)
    {
        startPage();
        List<CrmInput> list = crmInputService.selectCrmInputList(crmInput);
        return getDataTable(list);
    }

    /**
     * 导出信息化投入现状列表
     */
    @PreAuthorize("@ss.hasPermi('system:input:export')")
    @Log(title = "信息化投入现状", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(CrmInput crmInput)
    {
        List<CrmInput> list = crmInputService.selectCrmInputList(crmInput);
        ExcelUtil<CrmInput> util = new ExcelUtil<CrmInput>(CrmInput.class);
        return util.exportExcel(list, "input");
    }

    /**
     * 获取信息化投入现状详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:input:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(crmInputService.selectCrmInputById(id));
    }

    /**
     * 新增信息化投入现状
     */
    @PreAuthorize("@ss.hasPermi('system:input:add')")
    @Log(title = "信息化投入现状", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CrmInput crmInput)
    {
        return toAjax(crmInputService.insertCrmInput(crmInput));
    }

    /**
     * 修改信息化投入现状
     */
    @PreAuthorize("@ss.hasPermi('system:input:edit')")
    @Log(title = "信息化投入现状", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CrmInput crmInput)
    {
        return toAjax(crmInputService.updateCrmInput(crmInput));
    }

    /**
     * 删除信息化投入现状
     */
    @PreAuthorize("@ss.hasPermi('system:input:remove')")
    @Log(title = "信息化投入现状", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(crmInputService.deleteCrmInputByIds(ids));
    }
}
